#include <iostream>
#include <string>
using namespace std;
string a, b;
void dp (string x, string y) {
	if (y.size() <= 0) {
		return;
	}
	char ch = y[y.size() - 1];
	cout << ch;
	int k = x.find (ch);
	dp (x.substr(0, k), y.substr(0, k));
	dp (x.substr(k + 1), y.substr(k, y.size() - k - 1));
}
int main () {
	while (cin >> b >> a) {
		dp (a, b);
		cout << endl;
	}
	return 0;
}
